package com.jsy.mini12306.ticketsales.controller;

import com.jsy.mini12306.ticketsales.entity.StationInLine;
import com.jsy.mini12306.ticketsales.service.StationToTrainLineService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: SongyangJi
 * @description:
 * @since: 2021/9/1
 */

@Slf4j
@RestController
@RequestMapping("stationScreen")
public class StationScreenController {

    @Resource
    StationToTrainLineService stationToTrainLineService;


    @GetMapping("/departureStation/{stationId}")
    public ResponseEntity<List<StationInLine>> getTrainsByDepartureStation(@PathVariable int stationId) {
        return ResponseEntity.ok(stationToTrainLineService.queryTrainLinesByDepartureStationId(stationId));
    }

    @GetMapping("/terminalStation/{stationId}")
    public ResponseEntity<List<StationInLine>> getTrainsByTerminalStation(@PathVariable int stationId) {
        return ResponseEntity.ok(stationToTrainLineService.queryTrainLinesByTerminalStationId(stationId));
    }

}
